var input = document.getElementById("inputimg"); 
input.onchange = function()
{
  var file = this.files[0];
  if (!!file)
  {
    var reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = function()
    {
      document.getElementById("fileimg").src=this.result;
    }
  }
}